package weifei.live.simulation.im.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.springframework.stereotype.Repository;
import weifei.live.simulation.im.cmd.Bullet;

import java.util.Date;



@Data
@EqualsAndHashCode(callSuper = true)
@TableName("group_live_stream_bullet_cache")
@Repository
public class GroupLiveStreamBulletCache extends Model<GroupLiveStreamBulletCache>
{
    @Getter
    public enum Column
    {
        ID("id"),
        GroupID("group_id"),
        SenderID("sender_id"),
        Content("content"),
        SendTime("send_time");

        final String name;

        Column(String name) { this.name = name; }
    }

    @TableId
    private Integer id;
    private Integer senderId;
    private Integer groupId;
    private String content;
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date sendTime;

    public GroupLiveStreamBulletCache() {}
    public GroupLiveStreamBulletCache(int senderId, int groupId, String content, Date sendTime)
    {
        this.senderId = senderId;
        this.groupId = groupId;
        this.content = content;
        this.sendTime = sendTime;
    }


    public Bullet toBullet()
    {
        return new Bullet(
          this.senderId,
          this.groupId,
          this.content,
          this.sendTime
        );
    }
}

